using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BHXH.Core.Domain;
using BHXH.Core.IService;
using FX.Data;
using NHibernate;

namespace BHXH.Core.ServiceImp
{
    public class hs_D02bTS_dtService: BaseService<hs_D02bTS_dt ,int>,Ihs_D02bTS_dtService
    {
        ISession mySession;
        public hs_D02bTS_dtService(string sessionFactoryConfigPath)
            : base(sessionFactoryConfigPath)
        {}

        public IList<hs_D02bTS_dt> GetAll_hs_d02btsdt()
        {
            var a = GetAll();
            return a;
        }

        public void Update_hs_d02btsdt(hs_D02bTS_dt hs)
        {
            hs_D02bTS_dt hsnew = new hs_D02bTS_dt();
            hsnew = hs;
            using (mySession = this.NHibernateSession.SessionFactory.OpenSession())
            {
                mySession.Update(hs);
                CommitChanges();
                mySession.Flush();
            }
        }

        public bool Add_hs_d02btsdt(hs_D02bTS_dt hs)
        {

            using (mySession = this.NHibernateSession.SessionFactory.OpenSession())
            {
                mySession.Save(hs);
                mySession.Flush();
                return true;
            }
        }

        public int Delete_hs_d02btsdt(string ID)
        {
            using (mySession = this.NHibernateSession.SessionFactory.OpenSession())
            {
                int a = mySession.CreateQuery("DELETE FROM hs_D02bTS_dt hs WHERE hs.ID=:id")
                    .SetParameter("id", int.Parse(ID))
                    .ExecuteUpdate();
                CommitChanges();
                mySession.Clear();
                return a;
            }
        }
    }

}